home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.03 Mar 90 / Mouse Source / TrackScrap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-22  |  2.2 KB  |  117 lines  |  [TEXT/KAHL]

  1. /*                                            TrackScrap.c                                        */
  2. /*
  3.  * Copyright © 1989 Martin Minow. All rights reserved.
  4.  *
  5.  * OSErr
  6.  * TrackFromScrap()
  7.  *
  8.  * Copy the desk scrap to the Track private scrap.
  9.  * Return noErr if successful, else an error code.
  10.  *
  11.  * OSErr
  12.  * TrackToScrap()
  13.  *
  14.  * Copy the Track private scrap to the desk scrap.
  15.  * Return noErr if successful, else an error code.
  16.  *
  17.  * Handle
  18.  * TrackScrapHandle()
  19.  *
  20.  * Return a handle to the Track private scrap.
  21.  *
  22.  * LONGINT
  23.  * TrackGetScrapLen()
  24.  *
  25.  * Return the length of the Track private scrap in bytes.
  26.  *
  27.  * TrackSetScrapLen(length)
  28.  * LONGINT        length;
  29.  *
  30.  * Set the size of the Track private scrap.  This will
  31.  * call SetHandleSize() on the track handle.
  32.  */
  33.  
  34. #include "TrackEdit.h"
  35.  
  36. /*
  37.  * TrackFromScrap()
  38.  * If there is a TEXT item in the desk scrap, read it in
  39.  * and store it in the Track private scrap.  Return
  40.  * the error status (noErr is normal, noTypErr means
  41.  * there wasn't any TEXT in the scrap, anything is
  42.  * is trouble.
  43.  */
  44. OSErr
  45. TrackFromScrap()
  46. {
  47.         long                offset;
  48.         Handle            scrap;
  49.         long                status;
  50.         
  51.         SetHandleSize(TrackScrpHandle, 0);
  52.         status = GetScrap(TrackScrpHandle, 'TEXT', &offset);
  53.         if (status >= 0) {
  54.             TrackScrpLength = status;
  55.             status = noErr;
  56.         }
  57.         return (status);
  58. }
  59.  
  60. /*
  61.  * TrackToScrap()
  62.  * Copy the current selection to the Desk scrap.  Return
  63.  * noErr if ok, else an error code.
  64.  */
  65. OSErr
  66. TrackToScrap()
  67. {
  68.         OSErr                            status;
  69.         
  70.         MoveHHi(TrackScrpHandle);
  71.         HLock(TrackScrpHandle);
  72.         status = PutScrap(
  73.                             TrackScrpLength, 'TEXT', *TrackScrpHandle);
  74.         HUnlock(TrackScrpHandle);
  75.         return (status);
  76. }
  77.  
  78. /*
  79.  * Handle
  80.  * TrackScrapHandle()
  81.  *
  82.  * Return a handle to the Track private scrap.  Note:
  83.  * this is the *real* handle, not a copy.
  84.  */
  85. Handle
  86. TrackScrapHandle()
  87. {
  88.         return (TrackScrpHandle);
  89. }
  90.  
  91. /*
  92.  * LONGINT
  93.  * TrackGetScrapLen()
  94.  *
  95.  * Return the length of the Track private scrap in bytes.
  96.  */
  97. LONGINT
  98. TrackGetScrapLen()
  99. {
  100.         return (TrackScrpLength);
  101. }
  102.  
  103. /*
  104.  * TrackSetScrapLen(length)
  105.  * LONGINT        length;
  106.  *
  107.  * Set the size of the Track private scrap.  This will
  108.  * call SetHandleSize() on the track handle.
  109.  */
  110. void
  111. TrackSetScrapLen(length)
  112. LONGINT            length;
  113. {
  114.         SetHandleSize(TrackScrpHandle, length);
  115.         TrackScrpLength = length;
  116. }
  117.